<?php
class Admin_Pages_Management_Controller extends Admin_Controller {

    public $restful = true;

    public function __construct()
    {
        parent::__construct();
        //--Your Code --//
        $this->theme->set_theme("admin") ;
        $this->theme->set_layout("default") ;
    }


    public function get_edit($id){
    	if (Auth::guest()) return Redirect::to('admin/login');
    	 
    	if (!Auth::check())
    	{
    		return Redirect::to('admin/login');
    	}else{
    		
       

    	$data['page']['info'] = DB::table('pages')->where('id','=',$id)->first();	
    		
    	

        $this->theme->title("Pages");
        return $this->theme->render('admin::pages.management',$data);
    }
    }

    public function post_edit(){

            $rules = array(
				'title' => 'required',
                'content' => 'required',
            	'meta_title' => 'required',	

            );

            $validator = Validator::make(Input::get(), $rules);

            $thisOrderID = Input::get('pageID');



            if( $validator->fails() )
            {
                return Redirect::back()->with_input()->with_errors($validator)->with('message','<div class="alert alert-warning">Invalid Operation !</div>');
            }
            else
            {
               
                DB::table('pages')
                    ->where('id', '=', $thisOrderID)
                    ->update(array(
                            'title' => Input::get('title'),
                    		'content' => Input::get('content'),
                    		'meta_title' => Input::get('meta_title'),
                    		'meta_keyword' => Input::get('meta_keyword'),
                    		'meta_description' => Input::get('meta_description'),
                        )
                    );
                return Redirect::back()->with('message','<div class="alert alert-info">Data Successfully updated !</div>');
            }

       
    }





}